package com.api.shopapi.service.impl;

import com.api.shopapi.entity.Building;
import com.api.shopapi.mapper.BuildingMapper;
import com.api.shopapi.service.BuildingService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service("BuildingServiceImplOne")
public class BuildingServiceImpl implements BuildingService {

    @Autowired
    private BuildingMapper buildingMapper;

    @Override
    public int insert(Building building) {
        return buildingMapper.insert(building);
    }

    @Override
    public int updateByBuildingCode(Building building) {
        return buildingMapper.updateByBuildingCode(building);
    }

    @Override
    public int deleteByBuildingCode(String buildingCode) {
        return buildingMapper.deleteByBuildingCode(buildingCode);
    }

    @Override
    public List<Building> getListAll() {
        return buildingMapper.getListAll();
    }

    @Override
    public Building getByBuildingCode(String buildingCode) {
        return buildingMapper.getByBuildingCode(buildingCode);
    }

    @Override
    public Building getByBuildingName(String name,String institutionCode) {
        return buildingMapper.getByBuildingName(name,institutionCode);
    }

    //根据staffCode查询全部
    @Override
    public List<Building> getListAllByInstitutionCode(String institutionCode){
        return buildingMapper.getListByStaffCode(institutionCode);
    }

    @Override
    public PageInfo<Building> getPageList(int pageIndex, int pageSize, String institutionCode, String name) {
        PageHelper.startPage(pageIndex, pageSize);
        List<Building> buildings = buildingMapper.getPageList(institutionCode,name);
        PageInfo<Building> pageInfo = new PageInfo<Building>(buildings);
        return pageInfo;
    }

    @Override
    public
    PageInfo<Building> pageByGovCode(int pageIndex, int pageSize, String governmentCode){
        PageHelper.startPage(pageIndex, pageSize);
        List<Building> buildings = buildingMapper.listByGovCode(governmentCode);
        PageInfo<Building> pageInfo = new PageInfo<Building>(buildings);
        return pageInfo;
    }

}
